<%@page import="login.Login"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
</head>
<body>
<%
	String CustEmail = request.getParameter("user");
	if (CustEmail != null){
		String passwordT = request.getParameter("pass");
		
/* 	 	out.println("<h2> CustEmail  </h2> " + CustEmail);
	 	out.println("<h2> passwordT  </h2> " + passwordT); */
	
		if ((CustEmail.equals("") || passwordT.equals(""))){
			out.println("<h2 style='color:red'> UserId and Password can not be blanks</h2>");
		}else{
			out.println("<h2> entro else :   </h2> ");
			Login myLogin =  new Login(CustEmail, passwordT);
		//	out.println("<h2> entro else myLogin.login :   </h2> " + (myLogin.login()) );
			if (myLogin.login()){
				request.getSession().setAttribute("loggedin", true);
				response.sendRedirect("index.php");
			}else{
				out.println("<h2 style='color:red'> UserId and Password are invalid</h2>");
			}
		}
		
	}
%>
	<form>
 		<fieldset>
 			
 			 UserId (e-mail): <input type="text" name="user" /><br />
 			 Password       : <input type="password" name="pass" /><br />
 			 				
 			 <input type="submit" value="Log in" />
 			
 		</fieldset>
 	</form>
</body>
</html>